package com.huawei.zyb.taskManager.domain.task.valueobject;

import java.util.Objects;

/**
 * 任务唯一标识值对象
 * 遵循DDD值对象设计原则：不可变性、值相等性、自验证
 */
public final class TaskId {
    private final Long value;

    private TaskId(Long value) {
        this.value = Objects.requireNonNull(value, "任务ID不能为空");
        if (value <= 0) {
            throw new IllegalArgumentException("任务ID必须为正数");
        }
    }

    public static TaskId of(Long value) {
        return new TaskId(value);
    }

    public Long getValue() {
        return value;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        TaskId taskId = (TaskId) obj;
        return Objects.equals(value, taskId.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(value);
    }

    @Override
    public String toString() {
        return "TaskId{" + value + "}";
    }
}